#include "RectangleModel.h"

RectangleModel* RectangleModel::rectangleModel = NULL;

RectangleModel* RectangleModel::initInstance(vector3 emergePoint, float pipeLength, float width, float height){
	if (rectangleModel == NULL){
		rectangleModel = new RectangleModel(emergePoint, pipeLength, width, height);
	}
	return rectangleModel;
}

RectangleModel* RectangleModel::getInstance(){
	if (rectangleModel == NULL){
		rectangleModel = new RectangleModel();
	}
	return rectangleModel;
}

vector3 RectangleModel::getPosition(){
	vector3 pos;
	int modX = width * 100;
	pos.x = (float)(rand() % modX) / 100 + emergePoint.x - width / 2;

	int modY = pipeLength * 100;
	pos.y = (float)(rand() % modY) / 100 + emergePoint.y;

	int modZ = height * 100;
	pos.z = (float)(rand() % modZ) / 100 + emergePoint.z - height / 2;

	return pos;
}

vector3 RectangleModel::getVelocity(){
	vector3 vel = vector3(0, -1, 0);
	vel *= this->velocity;
	return vel;
}